<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>颜料配置管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/jiujiudevice/jiuInk?deviceSn=${jiuInk.deviceSn }">墨盒配置列表</a></li>
		<li class="active"><a href="${ctx}/jiujiudevice/jiuInk/form?id=${jiuInk.id}">墨盒配置<shiro:hasPermission name="jiujiudevice:jiuInk:edit">${not empty jiuInk.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="jiujiudevice:jiuInk:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="jiuInk" action="${ctx}/jiujiudevice/jiuInk/save?deviceSn=${jiuInk.deviceSn }" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">设备Sn:</label>
			<div class="controls">
			    <input type="number" value="${jiuInk.deviceSn }"  name="name" disabled />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">编号:</label>
			<div class="controls">
			    <input type="number" value="${jiuInk.name }"  name="name" />
				<span style="color:grey;"> (填入数字(1-8)，对应设备路线)</span>	
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">颜色:</label>
			<div class="controls">
            <input type="text" value="${jiuInk.color }"  name="color" />
			   <span style="color:grey;"></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">单价:</label>
			<div class="controls">
            <input type="number" value="${jiuInk.price }"  name="price" onkeyup="clearNoNum(this)"/>
			   <span style="color:grey;">单位(元/g)</span>			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="jiujiudevice:jiuInk:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
		<script language="JavaScript" type="text/javascript"> 
    function clearNoNum(obj){ 
    obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
    obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数  
    if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额 
        obj.value= parseFloat(obj.value); 
    } 
} 
</script>
</body>
</html>
